﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using DQYT.HTDZ.BLL;
using DQYT.HTDZ.Model;
using DQYT.HTDZ.Common;
using DQYT.HTDZ.BusinessService;
namespace WebApplication1
{
    /// <summary>
    /// 回应前台页面数据请求，从数据库中查询数据
    /// </summary>
    public class ajax1 : IHttpHandler
    {
        /// <summary>
        /// 获取前台请求的一条曲线的id号和描图参数，以xml形式返回一组数据
        /// </summary>
        /// <param name="context"></param>
        public void ProcessRequest(HttpContext context)
        {

            string strId = context.Request.Params["id"].ToString(); 
            string strField = context.Request.Params["field"].ToString();
            DataTable dt = getDrawSingleData(strId,strField);//获得单井单日期数据
            dt.TableName = "table";
            dt.Columns[0].ColumnName = "l";
            DataSet ds = new DataSet();
            ds.DataSetName = "tables";
            ds.Tables.Add(dt);
            context.Response.ContentType = "application/xml";
            context.Response.Write(ds.GetXml());
            context.Response.End();
            
        }
  
        /// <summary>
        /// 获取单条数据
        /// </summary>
        /// <param name="ID"></param>
        /// <param name="drawCan"></param>
        public DataTable getDrawSingleData(string ID,string drawCan)
        {
            DrawFunc drawFunc = new DrawFunc();
            decimal id=Convert.ToDecimal(ID);
            string strSql = "select CJSJ FROM BDDATESOURSE  where ID='" + id + "'";
            BDDATESOURSEBLL bll = new BDDATESOURSEBLL();
            DataTable drawTb = bll.GetList_SQL(strSql).Tables[0];//获得一条记录
            byte[] btCjsj =(byte[]) drawTb.Rows[0]["CJSJ"];
            List<CJSJModel> cjsjModels = BinarySerializer.DeserializeObject<List<CJSJModel>>(btCjsj);
            drawTb = drawFunc.listCJSJModelToDataTable(cjsjModels, drawCan);//提取欲描图参数
            return drawTb;
            
        }
        
        /// <summary>
        /// 
        /// </summary>
        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    }
}